package com.guodefu.unifiedresponse.exception;


import com.guodefu.unifiedresponse.IResult;
import lombok.Getter;
import lombok.Setter;

import java.io.Serial;

/**
 * 业务异常类
 *
 * @author guodefu909
 **/
public class BusinessException extends BaseException {

	@Serial
	private static final long serialVersionUID = 1L;

	/**
	 * 需返回前端的额外信息，如测试时将更多信息返回给前端，更方便排查
	 */
	@Setter
	@Getter
	private String detail;

	private BusinessException(IResult resultCode, String message) {
		super(resultCode, message);
	}

	private BusinessException(IResult resultCode, String message, Throwable cause) {
		super(resultCode, message, cause);
	}

	public static BusinessException instance(IResult resultCode, String message) {
		return new BusinessException(resultCode, message);
	}

	public static BusinessException instance(IResult resultCode, String message, Throwable cause) {
		return new BusinessException(resultCode, message, cause);
	}

}
